package org.zjt.design.pattern;

import static java.lang.System.out;
/**
 * @author <a href="juntao.zhang@qq.com">juntao.zhang</a>
 * @Description: 工厂模式、抽象工厂模式
 * @Package org.zjt.design.pattern
 * @date 2018/5/8 14:26
 * @see
 */

interface ProductA{

    String name();
}

interface ProductB{
    String name();
}


/**
 * 抽象工厂模式
 */
abstract class AbstractFactory{

    public abstract ProductA createProductA();

    public abstract ProductB createProductB();

}


/**
 * 工厂模式
 */
class Factory extends AbstractFactory{

    @Override
    public ProductA createProductA() {
        return () -> "ProductA";
    }

    @Override
    public ProductB createProductB() {
        return () -> "ProductB";
    }
}

public class FactoryTest {

    public static void main(String[] args) {
        AbstractFactory factory = new Factory();
        out.println(factory.createProductA().name());
        out.println(factory.createProductB().name());
    }

}
